Repository navigation
fix(service-analytics): a lookup dataset dimension serves the referenced record's name for a relationship path and for a target titled by its nameField - #33136
Conversation
…ect and the target's nameField A relationship-path dimension (hop.column) now reads its column's field meta on the object the path's last hop reaches, named by the one hop resolver the query joins with, in the display pass and the sort-key pass. The label read prefers the target object's declared nameField before the name/title/label/first-text convention. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzrvnam3RUBqcsfRHq
…; changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzrvnam3RUBqcsfRHq
Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01L9qibzrvnam3RUBqcsfRHq
📓 Docs Drift CheckThis PR changes 1 package(s): 17 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: ⛔ 3 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails. What this run could not see
Coarse fallback — 10 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin b839115baa8703efe1313eac892a42eb2b705bc5 && git checkout b839115baa8703efe1313eac892a42eb2b705bc5
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5b2ec820c8abca113eae23745f71331f55ec7aed 99fa452be030d5ac9775b4a16db085053ac16f60 && git checkout -B drift-repro 5b2ec820c8abca113eae23745f71331f55ec7aed && git merge --no-ff 99fa452be030d5ac9775b4a16db085053ac16f60
node scripts/docs-audit/affected-docs.mjs --json 5b2ec820c8abca113eae23745f71331f55ec7aed
|
|
domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx 维护者速读 · PR #33136 @
|
Requested by Tesla · project thread
Fixes #33107
Clause-②: no
Metadata-protocol: none
维护者速读
account.owner_id,显示负责人的名字);二是目标对象以nameField作标题(如自动编号的订单号SO-2026-0002)。排序也按显示的名称排。nameField。service-analytics的标签读取,不改查询、分组和规格(Clause-② no,元数据协议不变)。分组仍按 id,两个同名的人仍是两行;API 不暴露的目标、行级权限隐藏的记录仍显示 id。注册表会给每个自有对象指定nameField,所以标题字段与旧规则不同的目标,现在显示的是平台其他地方显示的那个标题。回滚就是还原本 PR。packages/services/service-analytics/src/dimension-labels.ts(dimensionColumn与pickDisplayField)、analytics-service.ts里columnObjectOfField(复用查询本身用的columnObjectOf)、plugin.ts的fetchRecordLabels。pnpm --filter @objectstack/rest exec vitest run src/analytics-dataset-lookup-dimension-labels.test.ts,预期 6 个全部通过(REST、query_dataset工具、直接调用三个入口给出同样带名称的行)。What changes
A, relationship-path lookups.
resolveDimensionLabelsand the sort-key resolver (createOrderLabelResolver) looked a dimension'sfieldup on the base object's field map only. A path such asaccount.owner_idfound no field meta there, so its FK id was served. Each dimension the service hands to the label passes now carriescolumnObject, the object the path's column lives on, and both passes read the column's meta (owner_id) on that object.columnObjectcomes fromcolumnObjectOf(hop-object.ts), over the compiled dataset cube's joins and the service'shopReference. That is the one hop resolver the query's joins, the field gate and the read scope already use, so the object labelled is the object the query read. The label module walks no path of its own.selectcolumn at the end of a path now serves its option label, translated under that object and column (translateSelectOptions(columnObject, column, …)).columnObjectreadsfieldverbatim on the base object, as before.B, targets titled by
nameField.pickDisplayField(fields, nameField?)returns the target's declarednameFieldfirst, when the field map declares it and it is not virtual (the spec'sisVirtualSearchField, i.e. not aformula). Otherwise it falls back to the old order:name,title,label, then the first text field.plugin.tsfetchRecordLabelspasses the target schema'snameField. Before this, a target titled by anautonumberwith noname/title/labelfield was read through its first text field, the platform-injected ownershipqueue, which is null on every row. No label came back and the id was served.Callers of
pickDisplayField. There is one production caller,plugin.tsfetchRecordLabels, and it now passesnameField. The other references are the package export (index.ts, where the added parameter is optional) and the tests indimension-labels.test.tsanddataset-reference-dimension-labels.test.ts, which call it withoutnameFieldand keep their answers. Nothing outsideservice-analyticsimports it (repo-wide grep overpackages/andui/).MCP
query_dataset. It does not have a label path of its own. The MCP tool (mcp-http-tools.ts) calls the runtime bridge (packages/runtime/src/domains/mcp.ts,service.datasetTools(…).queryDataset), which callsAnalyticsService.queryDataset, which runs this label pass. The new integration test pins that thequery_datasetexecutor serves the same labelled rows as the REST door.packages/mcpis not touched.Tests
packages/rest/src/analytics-dataset-lookup-dimension-labels.test.ts(new) runs on a realObjectQLengine over SQLite, with the analytics serviceAnalyticsServicePluginregisters and its realfetchRecordLabelsbridge. Every case asserts that three faces return equal rows:POST /analytics/dataset/querywithdatasetName, thequery_datasettool executor, and the directqueryDatasetcall. The cases:account.owner_idis labelled with the rep's name. Two reps who share the name "Sam Lee" stay two rows, because grouping is by id.orderasc on that dimension sorts by name, andlimit: 1takes its window over that order. The ids sort the opposite way.cb_order.carbon_grade, is labelled with the grade name.account.region, whose label target declaresenable.apiEnabled: false, still renders the stored id.autonumbernameFieldtarget, with the injectedqueuefield ahead of it, is labelled with the order number.namefield labels as before.dimension-labels.test.ts, in its existingpickDisplayFielddescribe:nameFieldcomes before the convention, the CONTROL cases (nameField: 'name', absent, empty) pick as before, and anameFieldmissing from the map or naming aformulafalls through. A new top-level describe covers relationship-path dimensions: a user column on the hop object, a select column translated under the hop object, an unresolved path that stays raw, and the sort-key pass on the same column.Acceptance notes
nameFieldreach is wider than the card's shape.SchemaRegistrydesignatesnameFieldon every owned object that has a title-eligible field (ADR-0079,provisionPrimarywithsynthesize: false). So the label read now follows each target's designated title, not only an explicit autonumber one. Where the old rule and the designated title already agree (an object with a textnamefield), nothing changes. Where they differ, for example an object whose title issubjectorfull_name, the dashboard now shows the title the rest of the platform shows for that record.nameFieldhas no column the label read (an aggregate grouped byidand the display field) can group by, so the label is read from the old convention, as before. Serving a formula title on this read would be its own change.displayNameField(the deprecated alias) is not read here. Schema parse copies it ontonameField, and the registry reads the parsed schema.orderbreaks the query. While building the fixture, a dataset withinclude: ['order']and a dimension on that field answered500 DATABASE_ERRORon the REST door (SQLite:near "order": syntax error), atorigin/mainand with this change alike. The fixture usescb_order, as the card does. This is reported to the seat to file. Dedupe words: dataset include reserved word, relationship alias unquoted, near order syntax error.packages/rest. That package hosts thePOST /analytics/dataset/queryroute, and its tests already build the real engine and plugin rig this test copies (analytics-dataset-ai-tools-parity.test.ts).Verification
On head
99fa452bunless stated. Head99fa452bdiffers from026cdd93only in a type annotation indimension-labels.test.ts.Measurement at origin/main 7c36f52 (the new integration test, before the fix)
4 failed, 2 passed. Each face returned the same rows, and the rows carried ids:
rep:rep_a,rep_b,rep_c(expected the names);rep_a,rep_b,rep_c(expectedSam Lee,Sam Lee,Zed Young);grade:gr_330,gr_550(expectedN330,N550);order:ord_1,ord_2(expectedSO-2026-0001,SO-2026-0002).The two that passed are the gated region case and the CONTROL.
Ablations (scripts/ablation-replace.mjs; service-analytics rebuilt each leg, marker proved in dist/ with ablation-dist-preflight.mjs, restored with the blob equal to HEAD, git diff HEAD empty and the marker proved absent)
dimensionColumnforced to ignorecolumnObject: the rest test has 3 red (rep label, sort, grade) and 3 green (region, B, CONTROL). The unit files have 3 red (the path describe's user, select and sort-key cases).nameFieldbranch disabled: 1 red in rest (the order number) and 1 red in the unit tests (nameField before the convention).withServedLabelTargetsmade to serve every target: 1 red in rest (the region path rendersEast) and 9 red indimension-label-exposure.test.ts.Suites, typecheck, lint, gates
pnpm --filter @objectstack/service-analytics test: 215 files, 5192 passed and 332 skipped (026cdd93).pnpm --filter @objectstack/rest test: 409 files, 8330 passed and 332 skipped (026cdd93).typecheck, which includes the test files: service-analytics exit 0 on99fa452b; rest exit 0 on026cdd93.pnpm lint: exit 0 (026cdd93).turbo run build --filter='!@objectstack/docs', noOS_SKIP_DTS): exit 0.dispatch-gates.mjs --commandsderived 72 gates. On026cdd93, 71 exited 0.check-plugin-teardown-shape.mjs --self-testexited 3 there because the shallow clone lacked its pinned fixture commit; after fetching621a4876it exited 0. All 72 were rerun on99fa452b, every one exit 0, anddispatch-gates.mjs --ran(with an exit code on every line) reports: 72 derived, 72 run, 0 NOT-MEASURED, 0 UNRUN. ESLint on the file changed after thepnpm lintrun: exit 0.🤖 Generated with Claude Code
https://claude.ai/code/session_01L9qibzrvnam3RUBqcsfRHq